/**
 * 新增标签页
 * 
 * @param id:
 *            标签页id
 * @param header:
 *            标签页标题
 * @param url:
 *            标签页内容的url链接
 */
function loadPage(id, header, cls, url) {
	var tab;
	tab = tabPanel.findById(id);
	if (tab != null) {
		tab.show();
		return;
	}
	tab = tabPanel.add({
		id : id,
		title : header,
		iconCls : cls,
		html : '<iframe frameborder="no" style="width:100%;height:100%" src="'
				+ url + '"></iframe>',
		closable : true
	});
	tab.show();
}

/**
 * 新增标签页
 */
function addPage(header, url) {
	var tabPanel = parent.parent.parent.tabPanel; // 多写几个parent为了以防在弹出窗口中调用
	var tab = tabPanel.add({
		title : header,
		html : '<iframe frameborder="no" style="width:100%;height:100%" src="'
				+ url + '"></iframe>',
		closable : true
	});
	tab.show();
}

/**
 * 用来弹出查看窗口页面
 * 
 * @param moduleId
 *            窗口id
 * @param title
 *            窗口标题
 * @param src
 *            链接
 * @param width
 *            宽度
 * @param height
 *            高度
 */
function createWindowView(moduleId, title, src, width, height) {
	parent.parent.parent.createDesktopWindow(moduleId, title, src, width,
			height);
}

function addStyledPage(header, cls, url) {
	var tabPanel = parent.parent.parent.tabPanel; // 多写几个parent为了以防在弹出窗口中调用
	var tab = tabPanel.add({
		title : header,
		iconCls : cls,
		html : '<iframe frameborder="no" style="width:100%;height:100%" src="'
				+ url + '"></iframe>',
		closable : true
	});
	tab.show();
}

/**
 * 关闭当前Tab
 */
function closeTab() {
	var tabs = parent.parent.parent.tabPanel; // 多写几个parent为了以防在弹出窗口中调用
	tabs.remove(tabs.activeTab);
}

/**
 * 绑定Form
 * 
 * @param formId:
 *            Form的Id
 * @param data:
 *            Json数据
 * @example bindForm("orgForm", jsonObject)
 */
function bindForm(formId, data) {
	var form = document.getElementById(formId);
	for ( var i = 0; i < form.elements.length; i++) {
		var element = form.elements[i];
		// if (!data[element.id]) continue;
		if (data[element.id] == undefined)
			continue;
		var val = data[element.id];
		switch (element.type) {
		case "text":
			;
		case "hidden":
			;
		case "password":
			element.value = val;
			break;
		case "textarea":
			element.value = val;
			break;
		case "radio":
		case "checkbox":
			if (val instanceof Array)
				element.checked = (val.indexOf(element.value) > -1);
			else
				element.checked = (element.value == val);
			break;
		case "select-one":
		case "select-multiple":
			for ( var j = 0; j < element.options.length; j++) {
				var option = element.options[j];
				if (val instanceof Array) {
					option.selected = (val.indexOf(option.value) > -1);
				} else {
					option.selected = (option.value == val);
				}
			}
			break;
		}
	}
}

/**
 * 通过Form绑定Json数据
 * 
 * @param formId:
 *            Form的Id
 * @param data:
 *            Json数据
 * @example bindForm("orgForm", jsonObject)
 */
function bindJson(formId, data) {
	var form = document.getElementById(formId);
	for ( var i = 0; i < form.elements.length; i++) {
		var element = form.elements[i];
		// if (!data[element.id]) continue;
		if (data[element.id] == undefined)
			continue;
		switch (element.type) {
		case "text":
			;
		case "hidden":
			;
		case "password":
			data[element.id] = element.value;
			break;
		case "radio":
		case "checkbox":
			data[element.id] = element.checked ? element.value : "N";
			break;
		case "select-one":
		case "select-multiple":
			data[element.id] = "";
			for ( var j = 0; j < element.options.length; j++) {
				var option = element.options[j];
				option.selected = (option.value == val);
				if (option.selected) {
					if (data[element.id] == "")
						data[element.id] = option.value;
					else
						data[element.id] = data[element.id] + ","
								+ option.value;
				}
			}
			break;
		}
	}
}

/**
 * 发送AJAX请求
 * 
 * @param serviceName:
 *            action的方法,格式为 package.class.method
 * @param 其后的参数以一对对“参数名-参数值”的方式
 * @example doService("admin.Main.changePwd", "oldpwd",1, "newpwd",2)
 */
function doService() {
	var params = doService.arguments;
	if (params.length % 2 == 0) {
		alert('参数错误!');
		return;
	}
	var serviceName = params[0];
	var urlParams = '';
	urlParams = arrayToUrl(urlParams, params, 1);
	return postService(serviceName, urlParams);
}

/**
 * 发送AJAX请求
 * 
 * @param serviceName:
 *            action的方法,格式为 package.class.method
 * @param formId:
 *            Form的Id
 * @param 其后的参数以一对对“参数名-参数值”的方式
 * @example doFormService("admin.Main.changePwd", "userForm", "oldpwd",1,
 *          "newpwd",2)
 */
function doFormService() {
	var params = doFormService.arguments;
	if (params.length < 2 || params.length % 2 != 0) {
		alert('参数错误!');
		return;
	}
	var serviceName = params[0];
	var formId = params[1];
	var urlParams = '';
	urlParams = formToUrl(urlParams, formId);
	urlParams = arrayToUrl(urlParams, params, 2);
	return postService(serviceName, urlParams);
}

/**
 * 把Form的所有项生成name1=value1&name2=value2&...的URL参数字符串
 * 
 * @private
 * @param urlParams:
 *            传入字符串
 * @param formId:
 *            Form的Id
 */
function formToUrl(urlParams, formId) {
	var els = document.getElementById(formId).elements;
	for ( var i = 0, max = els.length; i < max; i++) {
		var el = els[i];
		var id = el.id;
		var value = el.value;
		if (!id)
			continue;
		if (urlParams != '')
			urlParams += "&";
		urlParams += id + "=" + encodeURI(value);
	}
	return urlParams;
}

/**
 * 把Form的所有项生成 对象.name1=value1&对象.name2=value2&...的URL参数字符串
 * 
 * @private
 * @param urlParams:
 *            传入字符串
 * @param formId:
 *            Form的Id
 */
function formToObjUrl(urlParams, formId, obj) {
	var els = document.getElementById(formId).elements;
	for ( var i = 0, max = els.length; i < max; i++) {
		var el = els[i];
		var id = el.id;
		var value = el.value;
		if (!id)
			continue;
		if (urlParams != '')
			urlParams += "&";
		urlParams += obj + "." + id + "=" + encodeURI(value);
	}
	return urlParams;
}

/**
 * 把数组的所有项生成name1=value1&name2=value2&...的URL参数字符串
 * 
 * @private
 * @param urlParams:
 *            传入字符串
 * @param params:
 *            函数所有参数的数组
 * @param start:
 *            从第几个参数开始截取
 */
function arrayToUrl(urlParams, params, start) {
	for ( var i = start; i < params.length - 1; i = i + 2) {
		if (urlParams != '')
			urlParams += "&";
		urlParams += params[i] + "=" + params[i + 1];
	}
	return urlParams;
}

/**
 * 把Form的所有项生成 {对象.name1=value1,对象.name2=value2,...}的URL参数字符串
 * 
 * @private
 * @param urlParams:
 *            传入字符串
 * @param formId:
 *            Form的Id
 */
function formToParms(urlParams, formId, obj) {
	var els = document.getElementById(formId).elements;
	for ( var i = 0, max = els.length; i < max; i++) {
		var el = els[i];
		var id = el.id;
		var value = el.value;
		if (!id)
			continue;
		if (urlParams != '')
			urlParams += ",";
		urlParams += obj + "." + id + ":" + value;
	}
	return '{' + urlParams + '}';
}

/**
 * 清空Form所有项
 * 
 */
function formClean(formId) {
	var els = document.getElementById(formId).reset();
}

/**
 * 发送AJAX请求
 * 
 * @private
 * @param serviceName:
 *            action的方法,格式为 package.class.method
 * @param urlParams:
 *            ajax请求的URL参数
 * @example postService("admin.Main.changePwd", "oldpwd=1&newpwd=2")
 */
function postService(serviceName, urlParams) {
	var jsonObject;
	$.ajax({
		type : "POST",
		url : ctx + "/" + serviceName.replace(/\./g, "/") + ".do",
		data : urlParams,
		dataType : "json",
		async : false,
		success : function(json) {
			jsonObject = json;
		}
	});
	return jsonObject;
}

function ajaxPost(url, urlParams, fn) {
	var jsonObject;
	$.ajax({
		type : "POST",
		url : url,
		data : urlParams,
		dataType : "json",
		// async: false,
		success : function(json) {
			jsonObject = json;
			fn(jsonObject);
		},
		error : function() {
			jsonObject = {
				success : false
			};
			fn(jsonObject);
		}
	});
	return jsonObject;
}

/**
 * 判断项是否为空，如果为空则提示错误
 * 
 * @param itemId:
 *            项的ID
 * @param itemPrompt:
 *            项的中文说明
 */
function checkItemNull(itemId, itemPrompt) {
	var item = document.getElementById(itemId);
	if (item == undefined)
		return;
	if (item.value == "") {
		alert(itemPrompt + "不能为空!");
		item.focus();
		throw "NULL";
	}
}

/**
 * 判断是否符合条件，如果符合则提示错误
 * 
 * @param condition:
 *            条件
 * @param message:
 *            错误信息
 */
function checkCondition(condition, message) {
	checkCondition(condition, message, null);
}

function checkCondition(condition, message, itemFocusing) {
	if (condition) {
		alert(message);
		if (itemFocusing != null) {
			var item = document.getElementById(itemFocusing);
			if (item != undefined)
				item.focus();
		}
		throw "CONDITION";
	}
}

// 格式化日期为yyyy.mm
function todate(s) {
	var str = "";
	if (s != "" && s.length >= 7) {
		str = s.substr(0, 4) + "." + s.substr(5, 2);
	}
	return str;
}
// 格式化日期为yyyy.mm.dd
function toYMDdate(s) {
	var str = "";
	if (s) {
		if (s != "" && s.length >= 10) {
			str = s.substr(0, 4) + "." + s.substr(5, 2) + "." + s.substr(8, 10);
		} else if (s != "" && s.length >= 5) {
			str = s + '.01';
		}
	}
	return str;
}
function WinOpen(url, height, width) {
	window
			.open(
					url,
					"",
					"height="
							+ height
							+ ",width="
							+ width
							+ ",top="
							+ getTop(heigth)
							+ ",left="
							+ getLeft(width)
							+ ",toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no,status=no");
}

function showConfirm(title, text, fn) {
	gisCover(true);
	Ext.MessageBox.show({
		title : title,
		msg : text,
		buttons : Ext.Msg.YESNO,
		icon : Ext.MessageBox.QUESTION,
		fn : function(){gisCover(false);}
	});
}

function showInfoMessage(title, text, eventFunction) {
	gisCover(true);
	Ext.MessageBox.show({
		title : title,
		msg : text,
		buttons : Ext.MessageBox.OK,
		icon : Ext.MessageBox.INFO,
		fn : function(){gisCover(false);}
	});
}

function showErrorMessage(title, text, eventFunction) {
	gisCover(true);
	Ext.MessageBox.show({
		title : title,
		msg : text,
		buttons : Ext.MessageBox.OK,
		icon : Ext.MessageBox.ERROR,
		fn : function(){gisCover(false);}
	});
}

function showWarningMessage(title, text, eventFunction) {
	gisCover(true);
	Ext.MessageBox.show({
		title : title,
		msg : text,
		buttons : Ext.MessageBox.OK,
		icon : Ext.MessageBox.WARNING,
		fn : function(){gisCover(false);}
	});
}

function delayRun(code, time) {
	var t = setTimeout(code, time);
}

/**
 * 发送地址单选 调用方式var combox=createComboxTree('divdiv');
 * 
 * @param comboxid,renderId
 * @returns {Ext.form.ComboBox}
 */
function createComboxTree(comboxid, renderId) {
	var comboxTree = new Ext.ux.ComboBoxTree({
		id : comboxid,
		renderTo : renderId,
		autoShow : true,
		tree : new Ext.tree.TreePanel({
			root : new Ext.tree.AsyncTreeNode({
				text : '--选择--',
				id : '0'
			}),
			rootVisible : false,
			border : false,
			dataUrl : '../node/node_info!listTree.action?parentNodeId=0',
			listeners : {
				beforeload : function(n) {
					if (n) {
						this.getLoader().baseParams.id = n.attributes.id;
					}
				}
			}
		})
	})

	comboxTree.render(renderId);
	return comboxTree;
}

/**
 * 地址多选组件 调用方式var combox=createComboBoxCheckTree('divdiv');
 * 
 * @param renderId
 *            渲染id
 * @param separator
 *            选中值分隔符
 * @returns {Ext.ux.ComboBoxCheckTree}
 */
function createComboBoxCheckTree(renderId, separator) {
	var comboBoxCheckTree = new Ext.ux.ComboBoxCheckTree({
		renderTo : renderId,
		width : 300,
		height : 150,
		tree : {
			xtype : 'treepanel',
			height : 100,
			// checkModel: 'single', //cascade selection
			onlyLeafCheckable : false,// all nodes with checkboxes
			animate : true,
			rootVisible : false,
			autoScroll : true,
			loader : new Ext.tree.TreeLoader({
				dataUrl : '../node/node_info!listTree.action?parentNodeId=0',
				baseAttrs : {
					uiProvider : Ext.ux.TreeCheckNodeUI
				}
			}),
			root : new Ext.tree.AsyncTreeNode({
				id : '0',
				text : 'root'
			}),
			bbar : [ {
				iconCls : 'x-btn-close',
				text : '关闭',
				handler : function() {
					comboBoxCheckTree.canCollapse = true;
					comboBoxCheckTree.collapse();
				}
			} ]
		},

		// define which node's value will be submited
		// all
		// folder
		// leaf
		selectValueModel : 'all',
		separator : separator

	});
	return comboBoxCheckTree;
}
/**
 * MsgType下拉列表 调用方式如： js: var combox=createComboBoxMsgType('msgType'); jsp:<input
 * type="text" id="msgType" name="msgType">
 * 获取值：Ext.getCmp('msgType'+'-id').getValue()
 * 
 * @param renderId
 *            渲染id
 * @returns {Ext.form.ComboBox}
 */
function createComboBoxMsgType(renderId) {
	var mstTypeStore = new Ext.data.Store(
			{
				proxy : new Ext.data.HttpProxy(
						{
							url : '/bbmock/businessobject/business_object!listMsgType.action?t='
									+ new Date().getTime()
						}),
				reader : new Ext.data.ArrayReader({}, [ {
					name : 'key'
				}, {
					name : 'value'
				} ])
			});

	var comboBox = new Ext.form.ComboBox({
		id : renderId + "-id",
		store : mstTypeStore,
		width : 128,
		displayField : 'value',
		valueField : 'key',
		typeAhead : true,
		mode : 'remote',
		forceSelection : true,
		triggerAction : 'all',
		emptyText : '请选择',
		renderTo : renderId,
		selectOnFocus : true
	});
	// comboBox.render(renderId);
	return comboBox;
}

function createBigComboBoxMsgType(renderId) {
	var mstTypeStore = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : '../businessobject/business_object!listMsgType.action?t='
					+ new Date().getTime()
		}),
		reader : new Ext.data.ArrayReader({}, [ {
			name : 'key'
		}, {
			name : 'value'
		} ])
	});

	var comboBox = new Ext.form.ComboBox({
		id : renderId + "-id",
		store : mstTypeStore,
		width : 200,
		displayField : 'value',
		valueField : 'key',
		typeAhead : true,
		mode : 'remote',
		renderTo : renderId,
		forceSelection : true,
		triggerAction : 'all',
		emptyText : '请选择',
		selectOnFocus : true
	});
	// comboBox.render(renderId);
	return comboBox;
}
/**
 * 系统代码下拉选择框 调用方式var combox=createSysCodeComboBox('divdiv','BLACK_BOX');
 * 
 * @param renderId
 * @returns {Ext.form.ComboBox}
 */
function createSysCodeComboBox(renderId, sysType) {
	var sysCodeStore = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : '../system/sys_code_type!listSysCode.action?t='
					+ new Date().getTime() + "&sysType=" + sysType
		}),
		reader : new Ext.data.JsonReader({}, [ {
			name : 'name'
		}, {
			name : 'value'
		} ])
	});
	var SysCodeComboBox = new Ext.form.ComboBox({
		id : renderId + "-id",
		store : sysCodeStore,
		width : 200,
		displayField : 'name',
		valueField : 'value',
		typeAhead : true,
		mode : 'remote',
		renderTo : renderId,
		forceSelection : true,
		triggerAction : 'all',
		emptyText : '请选择',
		selectOnFocus : true
	});
	// comboBox.render();
	return SysCodeComboBox;
}

/**
 * 增加extjs的combox组件验证功能样式 例如：addComboxValidateCss("getLaneCode",
 * "{required:true}")
 * 
 * @param id
 * @param classCss
 *            2012-7-17 12:14:50
 */
function addComboxValidateCss(id, classCss) {
	// $("#getLaneCode").find("div input").addClass("{required:true}");
	$("#" + id).find("div input").addClass(classCss);
}

/**
 * 
 * 更新select数据 例如： updateSelectStructTagValue("getTest",
 * "../multicastchannel/multicast_channel!getNotUseGetLaneCode.action", "t=" +
 * new Date().getTime(), "getLaneCode", "getLaneCode");
 * 
 * @param id
 *            select的Id,id是唯一的
 * @param url
 *            action的url
 * @param parame
 *            参数
 * @param valueName
 *            值名称
 * @param labelName
 *            标签名称
 */
function updateSelectStructTagValue(id, url, parame, valueName, labelName) {
	ajaxPost(url, parame, function(response) {
		if (response.success != 'true') {
			$("#" + id).html("<option  value=''>请选择...</option>");
			if (response.result.length != 0) {
				for ( var i = 0; i < response.result.length; i++) {
					$("<option>").attr("value", response.result[i][valueName])
							.html(response.result[i][labelName]).appendTo(
									$("#" + id));
				}
			}
		} else {
			$("#" + id).html("<option  value=''>请选择...</option>");
			// $("#"+ id).html("<option selected='selected'
			// value=''>请选择...</option>");
		}
	});
}
/**
 * 更新form下的select数据
 * 
 * @param id
 *            不同form下id可以重复
 * @param url
 * @param parame
 * @param valueName
 * @param labelName
 */
function updateFormSelectStructTagValue(formId, selectId, url, parame,
		valueName, labelName) {
	ajaxPost(url, parame,
			function(response) {
				if (response.success != 'true') {
					$(
							"form[id='" + formId + "']" + " select[id='"
									+ selectId + "']").html(
							"<option  value=''>请选择...</option>");
					if (response.result.length != 0) {
						for ( var i = 0; i < response.result.length; i++) {
							$("<option>").attr("value",
									response.result[i][valueName]).html(
									response.result[i][labelName])
									.appendTo(
											$("form[id='" + formId + "']"
													+ " select[id='" + selectId
													+ "']"));
						}
					}
				} else {
					$(
							"form[id='" + formId + "']" + " select[id='"
									+ selectId + "']").html(
							"<option  value=''>请选择...</option>");
					// $("#"+ id).html("<option selected='selected'
					// value=''>请选择...</option>");
				}
			});
}

/**
 * 根据JSON转为的时间对象，转化为格式化的时间字符串
 * 
 * @param dateObj
 *            时间对象
 * @return "yyyy-MM-dd HH:mm:ss"
 */
function getDateStrByDateObj(dateObj) {
	if (dateObj && dateObj.time) {
		var d = new Date(dateObj.time);
		if (d) {
			return d.getFullYear()
					+ "-"
					+ ((d.getMonth() + 1)<10 ? ("0"
							+ (d.getMonth() + 1)) : (d.getMonth() + 1)) + "-"
					+ (d.getDate()<10?("0"+d.getDate()):d.getDate()) + " " + (d.getHours()<10?("0"+d.getHours()):d.getHours()) + ":" + (d.getMinutes()<10?("0"+d.getMinutes()):d.getMinutes())
					+ ":" + (d.getSeconds()<10?("0"+d.getSeconds()):d.getSeconds());
		}
	}
}

/**
 * 根据表单ID和下拉框ID找出syscode集合，用于前端显示的逻辑判断
 * 
 * @param formId
 *            表单ID
 * @param formId
 *            下拉框ID
 * @return {object} syscode集合
 */
function getSysCodesForUI(formId, selectId) {
	var objs = {};
	var opts = $("#" + formId).find("select#" + selectId).find("option");
	$.each(opts, function() {
		if ($(this).attr("value")) {
			objs[$(this).attr("value")] = $(this).text();
		}
	});
	return objs;
}


/**
 * 把Form的所有项生成 [{"name":"user_name","value":"Jone"}...]的对象数组
 * 说明：radio、checkbox 以name绑定；其它数据，以id绑定。
 * 
 * @param formId: Form的Id
 * @param objParms: 需要添加至的数组对象，可为空。
 * @param suffix: form元素后缀名(对象.name = 表单名-后缀名)
 * 
 * @return objParms:返回对象数组
 * 	EXP:
 * 	[{"name":"user_name","value":"Jone"},{"name":"user_pwd","value":"123456"},...]
 *  	checkbox的"value":"val1,val2,val3..."
 */
function formToObjParms(formId,objParms,suffix) {
	if (!suffix) suffix="";
	var $form = $("#"+formId);
	var $txt = $form.find("input:text,input[type='hidden'],input:password,textarea,input:file");
	var $radio = $form.find("input:radio:checked");
	var $checkbox = $form.find("input:checkbox");
	var $select = $form.find("select");
	if(!objParms || !(objParms instanceof Array)){
		objParms = new Array();
	}
	/*普通键值对处理*/
	$.each($txt,function(i,n){
		var elementId=$(this).attr("id");
		if(elementId && elementId.length>0){
			var elementVal=$(this).val();
			objParms = pushObjForFormToObjParms(elementId,elementVal,objParms,suffix);
		}
	});
	/*$radio处理*/
	$.each($radio,function(){
		var elementName = $(this).attr("name");
		if(elementName && elementName.length>0){
			var elementVal = $(this).val();
			objParms = pushObjForFormToObjParms(elementName,elementVal,objParms,suffix);
		}
	});
	/*$checkbox处理*/
	var checkboxArray = new Array();
	$.each($checkbox,function(){
		var checkboxName = $(this).attr("name");
		if($.inArray(checkboxName, checkboxArray)<0){
			checkboxArray.push(checkboxName);
		}
	});
	$.each(checkboxArray,function(ci,cn){
		var $checkboxName = cn;
		var $ccheckbox = $form.find("input:checkbox[name='"+$checkboxName+"']:checked");
		var rval = "";
		$.each($ccheckbox,function(){
			rval += $(this).val() + ",";
		});
		if(rval && rval.length > 0){
			rval = rval.substring(0,rval.length-1);
		}
		objParms = pushObjForFormToObjParms($checkboxName,rval,objParms,suffix);
	});
	checkboxArray = null;
	/*$select处理*/
	$.each($select,function(){
		var elementId = $(this).attr("id");
		if(elementId && elementId.length>0){
			var elementVal = $(this).val();
			objParms = pushObjForFormToObjParms(elementId,elementVal,objParms,suffix);
		}
	});
	return objParms;
}

function pushObjForFormToObjParms(name,value,objParms,suffix){
	if(name && name.length >0){
		if(!value){
			value="";
		}
		if(suffix && suffix.length>0){
			name=name.substring(0,name.indexOf(suffix));
		}
		objParms.push({"name":name,"value":value});
	}
	return objParms;
}

/**
 * GIS遮盖层开关
 * @param {boolean} bCover  
 */
function gisCover(bCover){
//	if(bCover){
//		$("#gis_iframe_cover").show();
//	}else{
//		$("#gis_iframe_cover").hide();
//	}
	if(bCover){
		$("#gis_content_content").hide();
	}else{
		$("#gis_content_content").show();
	}
}

/**@author hutao
 * @tab公共方法
 * @param title
 * @param url
 * @return
 */
function linkTab(title,url){
//	url=$("#rootPath").val()+url;
	url=getRootPath()+"/"+url;
	var obj=new Object();
	obj.childMenuName=title;
	obj.hrefUrl=url;
	parent.$(".jericho_tabs").each(function (index){
		var tempTitle=$(this).attr("name");
		if(tempTitle==title){
			var id=$(this).attr("id");
			//jerichotab_
			id=id.substr(11,id.length);
			obj.childAttr="childAttr";
			obj.jerichotabindex=id;
		}
	});
	parent.addTab($(obj));
}
function getRootPath(){
    var curWwwPath=window.document.location.href;
    var pathName=window.document.location.pathname;
    var pos=curWwwPath.indexOf(pathName);
    var localhostPaht=curWwwPath.substring(0,pos);
    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
    return(localhostPaht+projectName);
}
function showArearList(selectId){
    var obj = $("#"+selectId);
	if(obj == null || obj == undefined){
    	alert(selectId+"在页面上没有定义！请定义！");
		return;
    }
	$("#"+selectId).empty();
	var str;
	 $.ajax({  
         async:false,//使用同步的Ajax请求  
          type: "POST",  
          dataType: "json",
          url: "../../businessSense/kqiSearch/getComboboxAreaData?col_area=xian",  
          success: function(data){  
        	signalProList=data;
      		if(null!=signalProList && undefined!=signalProList && signalProList!="undefined" && signalProList!=""){
      			for(var m=0;m<signalProList.length;m++){
      				var json=signalProList[m];
      				str+="<option value="+json.text+">"+json.text+"</option>";
      			}
      		}
      		$("#"+selectId).append(str);
          },
          error:function(data){
        	  alert(data.msg);
        	  $("#"+selectId).append(str);
          }
      }); 
}

/**
 * *@author hutao
 * @param selectId
 */
function showUserGroupList(selectId){
    var obj = $("#"+selectId);
	if(null==obj || obj == undefined){
    	alert(selectId+"在页面中不存在，请正确传入用户组下拉框ID");
		return;
    }
	$("#"+selectId).empty();
	var str="<option value=''>全部 </option>";
	 $.ajax({  
         async:false,//使用同步的Ajax请求  
          type: "POST",  
          dataType: "json",
          url: "../../sys/userGroupManage/getUserGroupList",  
          success: function(data){  
      		if(null!=data && undefined!=data && data!="undefined" && data!=""){
      			for(var m=0;m<data.length;m++){
      				var json=data[m];
      				str+="<option value="+json.group_id+">"+json.group_name+"</option>";
      			}
      		}
      		$("#"+selectId).append(str);
          },
          error:function(data){
        	  alert(data.msg);
        	  $("#"+selectId).append(str);
          }
      }); 
}
